class Student(object):
    pass
s = Student()
s2 = Student()
# 可以在外部将函数给定义好，注意self参数不能少。再将这个函数赋值给类
def p(self):
    print("hello Student")

Student.Print = p
s.Print()
s2.Print()  

# 但是，如果我们想要限制实例的属性怎么办？比如，只允许对Student实例添加name和age属性。
class People(object):
    __slots__ = ('name','age')
people = People()
people.name = "people"
people.age = 12
people.address = "beijing" #会失败，因为不在__slots__的范围之内
print(people.name)
print(people.age)
print(people.address)

# 注意：这个__slots__限制只是对当前类有效，对子类无效。